package com.kmxd.ams.controller.archive;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kmxd.ams.client.archive.IArchiveSealSvc;
import com.kmxd.ams.client.archive.dto.ArchiveSealAddDTO;
import com.kmxd.ams.client.archive.dto.ArchiveSealEditDTO;
import com.kmxd.ams.client.archive.dto.ArchiveSealQueryDTO;
import com.kmxd.ams.client.archive.vo.ArchiveSealListVO;
import com.kmxd.ams.client.archive.vo.ArchiveSealVO;
import com.kmxd.ams.core.log.annotation.AutoLog;
import com.kmxd.ams.core.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 档号章设置 前端控制器
 *
 * @author ZuoLG
 * @since 2023-09-11
 */
@RestController
@Tag(name = "档号章设置")
@RequestMapping("/archive/archiveSeal")
@AllArgsConstructor
public class ArchiveSealCtl {

  private IArchiveSealSvc archiveSealService;

  /** 分页查询 */
  @Operation(summary = "分页查询")
  @RequestMapping("/selectPage")
  @AutoLog(module = "档号章设置", title = "分页查询")
  public R<Page<ArchiveSealListVO>> selectPage(Page reqPage, ArchiveSealQueryDTO req) {
    return R.success(archiveSealService.selectPage(reqPage, req));
  }

  /** 列表查询 */
  @Operation(summary = "列表查询")
  @RequestMapping("/selectList")
  @AutoLog(module = "档号章设置", title = "列表查询")
  public R<List<ArchiveSealListVO>> selectList(ArchiveSealQueryDTO req) {
    return R.success(archiveSealService.selectList(req));
  }

  /** 新增 */
  @Operation(summary = "新增")
  @PostMapping("/add")
  @AutoLog(module = "档号章设置", title = "新增")
  public R<Void> add(@Validated @RequestBody ArchiveSealAddDTO req) {
    archiveSealService.add(req);
    return R.success();
  }

  /** 修改 */
  @Operation(summary = "修改")
  @PostMapping("/edit")
  @AutoLog(module = "档号章设置", title = "修改")
  public R<Void> edit(@Validated @RequestBody ArchiveSealEditDTO req) {
    archiveSealService.edit(req);
    return R.success();
  }

  /** 删除 */
  @Operation(summary = "删除")
  @PostMapping("/remove")
  @AutoLog(module = "档号章设置", title = "删除")
  public R<Void> remove(@RequestParam String ids) {
    archiveSealService.remove(ids);
    return R.success();
  }

  /** 查看 */
  @Operation(summary = "查看")
  @GetMapping("/view")
  @AutoLog(module = "档号章设置", title = "查看")
  public R<ArchiveSealVO> view(@RequestParam Long id) {
    return R.success(archiveSealService.view(id));
  }
}
